﻿using SafoverWpfFw;
using System;
using System.Globalization;
using Safover.LidarCollector.Core;

namespace Safover.LidarCollector.Converter
{
    public class DeviceConditionToBrushConverter : BaseValueConverter<DeviceConditionToBrushConverter>
    {
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return DoConvert(value);
        }

        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        private object DoConvert(object value) 
        {
            DeviceCondition condition = (DeviceCondition)value;

            switch (condition)
            {
                case DeviceCondition.Unavailable:
                    return System.Windows.Media.Brushes.OrangeRed;
                case DeviceCondition.Malfuntion:
                    return System.Windows.Media.Brushes.Gray;
                case DeviceCondition.OK:
                default:
                    return System.Windows.Media.Brushes.LightGreen;
            }
        }
    }
}
